<template>
  <div class="container">
    <div>
      <Logo />
      <h1 class="title">
        nuxt-demo
      </h1>
      <div class="links">
        <a
          href="https://nuxtjs.org/"
          target="_blank"
          rel="noopener noreferrer"
          class="button--green"
        >
          Documentation
        </a>
        <a
          href="https://github.com/nuxt/nuxt.js"
          target="_blank"
          rel="noopener noreferrer"
          class="button--grey"
        >
          GitHub
        </a>
      </div>
      <nuxt-content :document="page" />
    </div>
  </div>
</template>

<script>
export default {
  fetch({ app }) {
    app.$log(this.$data)
  },
  async asyncData({ $content, app }) {
    app.$log('get anync data, which returned will merge with data')
    const page = await $content('hello').fetch()
    return new Promise((resolve) => {
      resolve({
        timestamp: new Date().toLocaleString('zh-CN', {
          month: '2-digit',
          day: '2-digit',
          hour: '2-digit',
          minute: '2-digit',
          second: '2-digit',
        }),
        page,
      })
    })
  },
  data: () => {
    return {
      fixibleHeight: 360,
    }
  },
  computed: {
    ua: () => this.$store.state.ua,
  },
  mounted() {
    this.$log(this.$store.state.ua, this.timestamp)
  },
  methods: {
    toggleHeight() {
      this.fixibleHeight = Math.floor(Math.random() * 3) * 240
    },
  },
}
</script>

<style scoped>
.container {
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.title {
  font-family: 'Quicksand', 'Source Sans Pro', -apple-system, BlinkMacSystemFont,
    'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  display: block;
  font-weight: 300;
  font-size: 100px;
  color: #35495e;
  letter-spacing: 1px;
}

.subtitle {
  font-weight: 300;
  font-size: 42px;
  color: #526488;
  word-spacing: 5px;
  padding-bottom: 15px;
}

.links {
  padding-top: 15px;
}
</style>
